var express = require('express');
var router = express.Router();
var mysql=require("../db.js");
router.post("/notebook",function(req,res,next){
  let {id,title,tags, content}=req.body;
  //插入html  用单引号
  console.log(content)
 mysql.query( `update notebook set title="${title}",tags="${tags}",content='`+String(content)+`' where id = ${id}`,(data)=>{
    res.json({
        flag:"1"
    })
  })
})  
router.post("/target",function(req,res,next){
  let {id,description,progress,time,setlevel}=req.body;
  
  mysql.query( `update target set description="${description}",progress="${progress}",time="${time}",setlevel="${setlevel}" where id = ${id}`,(data)=>{
    res.json({
        flag:"1"
    })
  })
})  
router.post("/savepass",function(req,res,next){
    let {id,type,account,pass}=req.body;
    mysql.query( `update savepass set type="${type}",account="${account}",pass="${pass}" where id = ${id}`,(data)=>{
      res.json({
          flag:"1"
      })
    })
})  
router.post("/card",function(req,res,next){
    let {id,account,bank,type,time,money}=req.body;
    mysql.query( `update card set account="${account}",bank="${bank}",type="${type}",time="${time}",money="${money}" where id = ${id}`,(data)=>{
      res.json({
          flag:"1"
      })
    })
})  
router.post("/tool",function(req,res,next){
    let {environment,orderdesc,folder,experience,id}=req.body;
    mysql.query( `update tool set environment="${environment}",orderdesc="${orderdesc}",folder="${folder}",experience="${experience}" where id = ${id}`,(data)=>{
      res.json({
          flag:"1"
      })
    })
})  
router.post("/commonurl",function(req,res,next){
    let {url,application,webname,id}=req.body;
    mysql.query( `update commonurl set url="${url}",application="${application}",webname="${webname}" where id = ${id}`,(data)=>{
      res.json({
          flag:"1"
      })
    })
}) 
router.post("/notepad",function(req,res,next){
    let {content,id}=req.body;
    mysql.query( `update notepad set content="${content}" where id = ${id}`,(data)=>{
      res.json({
          flag:"1"
      })
    })
})
router.post("/spider",function(req,res,next){
  let {id,webname,programaddress,sheetname}=req.body;
  console.log(`update spider set webname="${webname}",programaddress="${programaddress}",sheetname="${sheetname}" where id = ${id}`)
  mysql.query( `update spider set webname="${webname}",programaddress="${programaddress}",sheetname="${sheetname}" where id = ${id}`,(data)=>{
    res.json({
        flag:"1"
    })
  })
})
module.exports = router;
